Music Object Extensibility API
|
|
Starting from version 3.1, the Music Object API has offered additional functionality in the form of optional Music Object extensions. With the release of version 3.3, the API (Application Programming Interface) for writing these extensions became official and public. This section explains the architecture upon which Music Object extensions, language modules, and patches are based and includes a reference to all the methods and properties of the extensibility API.
The following sample code listing provides a template that can be used as a starting point for creating your own custom Music Object extensions...
|
|
/**********
TITLE: Music Object Extension - MyExtensionName
VERSION: 1.0.0
AUTHOR: Whoever I Am
COPYRIGHT: 1999 MyCompany, Inc. All Rights Reserved
REQUIRES: music-object.js (3.2.0 or higher)
**********/
function mo_myInstanceMethod (someParam1,someParam2,someParamN) {
// some code to implement this instance method
}
function mo_myStaticMethod (someParam1,someParam2,someParamN) {
// some code to implement this static method
}
/*** Instance Extenders ***/
function mo_addMyExtensionInstanceProperties (ID) {
ID.myExtensionInstanceProperty1 = false;
ID.myExtensionInstanceProperty2 = 0;
//...
//...
ID.myExtensionInstancePropertyN = null;
}
Music.addInstanceExtender (mo_addMyExtensionInstanceProperties);
/*** Public Instance Methods ***/
Music.addPublicInstanceMethods ('myInstanceMethod');
/*** Public Static Methods ***/
Music.addPublicStaticMethods ('myStaticMethod');
/*** Public Static Properties ***/
Music.myExtensionStaticProperty1 = false;
Music.myExtensionStaticProperty2 = 0;
//...
//...
Music.myExtensionStaticPropertyN = null;
|
|
Extensibility API Reference
|
| Name |
Short Description |
| Instance Methods |
| getPlayer |
Returns an object reference, being a handle to the player object instance that is supporting the Music Object instance. |
| setPlayer |
Lets you set the player object instance that should support the Music Object instance. |
| Instance Properties |
| objectName |
A string variable, indicating the name of the window object's property that can be used to reference the Music Object instance. |
| volumeScalars |
An array, containing elements for all of the custom volume scalars that have been created for a Music Object instance. |
| Static Methods |
| Music.addEventHandler |
Lets you attach an additional event handler to an event that may already have a handler registered. |
| Music.addInstanceExtender |
Lets you register an extender function that will be called at the time of creation of each Music Object instance. |
| Music.addKnownClient |
Lets you add a client profile to the list of supported clients, with the assumption that the extension calling this method may implement code necessary to support the client. |
| Music.addPrivateInstanceMethods |
Lets you register the names of private instance methods that should extend each Music Object instance that is created. |
| Music.addPublicCallbacks |
Lets you register the names of public instance and static callbacks. |
| Music.addPublicInstanceMethods |
Lets you register the names of public instance methods that should extend each Music Object instance that is created. |
| Music.addPublicStaticMethods |
Lets you register the names of static methods that should extend the Music Object. |
| Music.appendToArray |
Lets you append the elements from one array onto another array. |
| Music.arrayOfObjects |
Offers a convenient way to create an array that is populated with a specified object type. |
| Music.checkForPlayer |
Lets you coerce the Music Object compatibility layer to check for an installed player. |
| Music.clearTimeout |
Lets you clear a timeout that is referenced from a property of a specified name that belongs to a specified object. |
| Music.execCallback |
Lets you execute the handler(s) for the specified static callback type. |
| Music.execHandler |
Lets you execute the specified handler code, regardless of whether it is specified as a function reference or as a string containing JavaScript. |
| Music.globalThru |
Returns a boolean value, indicating whether or not there is a Music Object instance ready through which to pass instructions to query or modify the global state of the audio engine. |
| Music.indexOf |
Finds the character position of a substring inside a source string, and returns the string length if the substring is not found. |
| Music.isInstance |
Returns a boolean value, indicating whether or not the specified object is a Music Object instance. |
| Music.meetsMinVersion |
Returns a boolean value, indicating whether or not a specified version number meets a specified minimum version number. |
| Music.doNothing |
A dummy method that does nothing and which can be passed as a parameter to functions or methods that take a function as a parameter. |
| Music.openWindow |
Lets you open a centered window of the specified size and properties, for the purposes of displaying prompt dialogs or informational messages. |
| Music.parseAttributes |
Lets you easily parse out HTML attributes from a string and return their values in a specified array. |
| Music.retrieveVersion |
Lets you extract just the version number out of the specified source string. |
| Music.setClientInfo |
Lets you explicitly set the client information that the Music Object compatibility component will use to determine whether or not the client is supported. |
| Music.stringHasAny |
Returns a boolean value, indicating whether or not the source string contains any of the specified substrings. |
| Music.tagAttr |
Returns a string value, being a name/value pair that is created from a property of a specified name that belongs to a specified object. |
| Music.wireMethod |
Lets you wire a Music Object method of a specified name to the specified object. |
| Static Properties |
| Music.client |
An object reference, being a reference to the last element of the Music.knownClients array that was successfully matched against the user's client application. |
| Music.enableJavaPrompt |
A static property that can be set in a language module so as to customize the message that appears when the user is prompted to enable Java in their browser. |
| Music.getPlayerText |
A static string property, representing the text that should appear in the player control panel substitute when the user needs to install the Beatnik Player. |
| Music.global |
A static property, indicating the Music Object instance that can be used to pass through instructions to query or modify the global state of the audio engine. |
| Music.installPrompt |
A static property that can be set in a language module so as to customize the message that appears when the user is prompted to install the Beatnik Player. |
| Music.knownClients |
An array, representing the list of client applications that are known by the compatibility component of the Music Object API. |
| Music.minFadeInterval |
An integer variable, specifying the minimum time interval between updates in the list of active fade tasks. |
| Music.publicInstanceCallbacks |
An array, containing the names of all the public instance callback types that have been registered using the Music.addPublicCallbacks static method. |
| Music.publicStaticCallbacks |
An array, containing the names of all the public static callback types that have been registered using the Music.addPublicCallbacks static method. |
| Music.upgradePrompt |
A static property that can be set in a language module so as to customize the message that appears when the user is prompted to upgrade their player version. |
| Music.upgradePlayerText |
A static string property, representing the text that should appear in the player control panel substitute when the user needs to upgrade their player version. |
| Global Variables |
| mo_delayPlayerCheck |
A global variable which, if defined with any value, indicates that the automatic player check should not be carried out at the time that the Music Object API loads and initializes. |
|
|
The getPlayer instance method returns an object reference, being a handle to the player object instance that is supporting the Music Object instance.
|
getPlayer ( ) |
|
OBJECT |
The setPlayer instance method lets you set the player object instance that should support the Music Object instance.
|
setPlayer ( PlayerReferenceOBJ ) |
The objectName instance property is a string variable, indicating the name of the window object's property that can be used to reference the Music Object instance.
The volumeScalars instance property is an array, containing elements for all of the custom volume scalars that have been created for a Music Object instance.
The Music.addEventHandler static method lets you attach an additional event handler to an event that may already have a handler registered.
|
Music.addEventHandler ( WindowOBJ , HtmlElementOBJ , EventTypeSTR , EventHandlerJavaScriptSTR ) |

- If an event of the name specified by the EventTypeSTR parameter does not exist for the specified HTML element, then the method will simply be ignored and will not produce any error.
The Music.addInstanceExtender static method lets you register an extender function that will be called at the time of creation of each Music Object instance.
|
Music.addInstanceExtender ( ExtenderFunction ) |
The Music.addKnownClient static method lets you add a client profile to the list of supported clients, with the assumption that the extension calling this method may implement code necessary to support the client.
|
Music.addKnownClient ( ClientNameSTR , ClientPlatformSTR , ClientMinVersionSTR , ClientIsUpgradableBOOL ) |

- Music.addKnownClient ( ClientNameSTR , ClientPlatformSTR , ClientMinVersionSTR , ClientIsUpgradableBOOL , CustomPropertiesOBJ )
When the optional CustomPropertiesOBJ parameter is specified, then all the properties of the object specified by the CustomPropertiesOBJ parameter will be copied to the object that is created by the Music.addKnownClient method. Among other things, this feature can be used to add notes regarding issues or limitations with the support for a specific known client, or to add notes regarding why a specific known client is not supported. Custom properties that are stored with a known client are simply ignored by the core Music Object API, and so it is up to the code that registeres such custom properties to make use of them as appropriate.
When specifying a value for the CustomPropertiesOBJ parameter, it is possible to create the object containing the custom properties directly in the call to the Music.addKnownClient method, as in the statement...
Music.addKnownClient (
'Some Browser',
'Win32,MacPPC',
'2.0 to 4.1',
true,
{
notes:'Certain maintenance release versions of this browser may not be supported.',
downloadURL:'http://www.somedomain.com/downloads/player-for-some-browser.cgi'
}
);
|
.
The Music.addPrivateInstanceMethods static method lets you register the names of private instance methods that should extend each Music Object instance that is created.
|
Music.addPrivateInstanceMethods ( MethodName1STR , MethodName2STR , ... , MethodNameNSTR ) |
The Music.addPublicCallbacks static method lets you register the names of public instance and static callbacks.
|
Music.addPublicCallbacks ( CallbackName1STR , CallbackName2STR , ... , CallbackNameNSTR ) |
The Music.addPublicInstanceMethods static method lets you register the names of public instance methods that should extend each Music Object instance that is created.
|
Music.addPublicInstanceMethods ( MethodName1STR , MethodName2STR , ... , MethodNameNSTR ) |
The Music.addPublicStaticMethods static method lets you register the names of static methods that should extend the Music Object.
|
Music.addPublicStaticMethods ( MethodName1STR , MethodName2STR , ... , MethodNameNSTR ) |
The Music.appendToArray static method lets you append the elements from one array onto another array.
|
Music.appendToArray ( DestinationArrayOBJ , SourceArrayOBJ ) |
The Music.arrayOfObjects static method offers a convenient way to create an array that is populated with a specified object type.
|
Music.arrayOfObjects ( TotalInstancesINT , ObjectConstructorFunction ) |
The Music.checkForPlayer static method lets you coerce the Music Object compatibility layer to check for an installed player.
|
Music.checkForPlayer ( ) |
The Music.clearTimeout static method lets you clear a timeout that is referenced from a property of a specified name that belongs to a specified object.
|
Music.clearTimeout ( TimeoutOwnerOBJ , TimeoutPropertyNameSTR ) |
The Music.doNothing static method is a dummy function that does nothing and which can be passed as a parameter to functions or methods that take a function as a parameter.
|
Music.doNothing ( ) |
The Music.execCallback static method lets you execute the handler(s) for the specified static callback type.
|
Music.execCallback ( StaticCallbackTypeSTR ) |
The Music.execHandler static method lets you execute the specified handler code, regardless of whether it is specified as a function reference or as a string containing JavaScript.

The Music.globalThru static method returns a boolean value, indicating whether or not there is a Music Object instance ready through which to pass instructions to query or modify the global state of the audio engine.
|
Music.globalThru ( ) |
The Music.indexOf static method finds the character position of a substring inside a source string, and returns the string length if the substring is not found.
|
Music.indexOf ( SourceSTR , SearchSTR , StartPosINT ) |
The Music.isInstance static method returns a boolean value, indicating whether or not the specified object is a Music Object instance.
|
Music.isInstance ( ObjectToTestOBJ ) |
The Music.meetsMinVersion static method returns a boolean value, indicating whether or not a specified version number meets a specified minimum version number.
|
Music.meetsMinVersion ( VersionToTestSTR , MinRequiredVersionSTR ) |
The Music.openWindow static method lets you open a centered window of the specified size and properties, for the purposes of displaying prompt dialogs or informational messages.
|
Music.openWindow (
FileUrlSTR ,
WindowNameSTR ,
WindowWidthINT ,
WindowHeightINT ,
ShowStatusBarBOOL ,
WindowPropertiesSTR ,
WindowLeftPositionINT ,
WindowTopPositionINT
)
|

- When a value of null is specified for the ShowStatusBarBOOL parameter, then the window that is opened by this method will by default have no status bar.
- When a value of null is specified for the WindowPropertiesSTR parameter, then an empty string will be used for this parameter.

- Music.openWindow ( FileUrlSTR , WindowNameSTR , WindowWidthINT , WindowHeightINT , ShowStatusBarBOOL , WindowPropertiesSTR , WindowLeftPositionINT )
When no WindowTopPositionINT parameter is specified, then the window will be centered vertically on the screen.
- Music.openWindow ( FileUrlSTR , WindowNameSTR , WindowWidthINT , WindowHeightINT , ShowStatusBarBOOL , WindowPropertiesSTR )
When there is also no WindowLeftPositionINT parameter specified, then the window will also be centered horizontally on the screen.
- Music.openWindow ( FileUrlSTR , WindowNameSTR , WindowWidthINT , WindowHeightINT , ShowStatusBarBOOL )
When there is also no WindowPropertiesSTR parameter specified, then the default window properties for this method will be used.
- Music.openWindow ( FileUrlSTR , WindowNameSTR , WindowWidthINT , WindowHeightINT )
When there is also no ShowStatusBarBOOL parameter specified, then the window that is opened by this method will by default have no status bar.

- The WindowNameSTR parameter may not contain any spaces or non-alphaneumeric characters, excepting the underscore character ("_").
The Music.parseAttributes static method lets you easily parse out HTML attributes from a string and return their values in a specified array.
|
Music.parseAttributes ( HtmlAttributesSTR , AttributesOwnerOBJ ) |
The Music.retrieveVersion static method lets you extract just the version number out of the specified source string.
|
Music.retrieveVersion ( SourceSTR ) |
The Music.setClientInfo static method lets you explicitly set the client information that the Music Object compatibility component will use to determine whether or not the client is supported.
|
Music.setClientInfo ( AppNameSTR , AppVersionSTR , PlatformSTR , UserAgentSTR ) |

- When a value of null is specified for the AppNameSTR parameter, then the value of the browser's navigator.appName property will be used for this parameter.
- When a value of null is specified for the AppVersionSTR parameter, then the value of the browser's navigator.appVersion property will be used for this parameter.
- When a value of null is specified for the PlatformSTR parameter, then the value of the browser's navigator.platform property will be used for this parameter, unless the platform can be determined from the value of the UserAgentSTR parameter.
- When a value of null is specified for the UserAgentSTR parameter, then the value of the browser's navigator.userAgent property will be used for this parameter.

- Music.setClientInfo ( AppNameSTR , AppVersionSTR , PlatformSTR )
When no UserAgentSTR parameter is specified, then the value of the browser's navigator.userAgent property will be used for this parameter.
- Music.setClientInfo ( AppNameSTR , AppVersionSTR )
When there is also no PlatformSTR parameter specified, then the value of the browser's navigator.platform property will be used for this parameter, unless the platform can be determined from the value of the UserAgentSTR parameter.
- Music.setClientInfo ( AppNameSTR )
When there is also no AppVersionSTR parameter specified, then the value of the browser's navigator.appVersion property will be used for this parameter.
- Music.setClientInfo ( )
When there is also no AppNameSTR parameter specified, then the value of the browser's navigator.appName property will be used for this parameter.
The Music.stringHasAny static method returns a boolean value, indicating whether or not the source string contains any of the specified substrings.
|
Music.stringHasAny ( SourceSTR , Substring1STR , Substring2STR , ... , SubstringNSTR ) |
The Music.tagAttr static method returns a string value, being a name/value pair that is created from a property of a specified name that belongs to a specified object.
|
Music.tagAttr ( PropertyOwnerOBJ , PropertyNameSTR ) |
The Music.wireMethod static method lets you wire a Music Object method of a specified name to the specified object.
|
Music.wireMethod ( MethodOwnerOBJ , MethodNameSTR ) |
The Music.client static property is an object reference, being a reference to the last element of the Music.knownClients array that was successfully matched against the user's client application.
The Music.enableJavaPrompt static property is a reference to a function and can be set in a language module so as to customize the message that appears when the user is prompted to enable Java in their browser.
For more information on using this property in conjunction with other Extensibility API properties in the creation of custom language modules, consult the section Creating Your Own Language Modules.
The Music.getPlayerText static property is a string, representing the text that should appear in the player control panel substitute when the user needs to install the Beatnik Player.
The Music.global static property is an object reference, indicating the Music Object instance that can be used to pass through instructions to query or modify the global state of the audio engine.
The Music.installPrompt static property is a reference to a function and can be set in a language module so as to customize the message that appears when the user is prompted to install the Beatnik Player.
For more information on using this property in conjunction with other Extensibility API properties in the creation of custom language modules, consult the section Creating Your Own Language Modules.
The Music.knownClients static property is an array, representing the list of client applications that are known by the compatibility component of the Music Object API.
The Music.minFadeInterval static property is an integer variable, specifying the minimum time interval between updates in the list of active fade tasks.
The Music.publicInstanceCallbacks static property is an array, containing the names of all the public instance callback types that have been registered using the Music.addPublicCallbacks static method.
The Music.publicStaticCallbacks static property is an array, containing the names of all the public static callback types that have been registered using the Music.addPublicCallbacks static method.
The static property is a string, representing the text that should appear in the player control panel substitute when the user needs to upgrade their player version.
The Music.upgradePrompt static property is a reference to a function and can be set in a language module, so as to customize the message that appears when the user is prompted to upgrade their player version.
For more information on using this property in conjunction with other Extensibility API properties in the creation of custom language modules, consult the section Creating Your Own Language Modules.
The mo_delayPlayerCheck global variable, if defined with any value, indicates that the automatic player check should not be carried out at the time that the Music Object API loads and initializes.
|
How Extensibility API Features are Divided Between the Core Components
|
The following table illustrates how the features (methods and properties) of the Music Object Extensibility API are broken up between the three core components. Each column of the table represents a core component, and each row in the table represents a type of extensibility feature (instance methods, static methods, instance properties, and static properties).